package 力扣.LCP_50_宝石补给;

public class Solution {
    public int giveGem(int[] gem, int[][] operations) {
        for (int[] operation : operations) {
            int x = gem[operation[0]] / 2;
            gem[operation[0]] -= x;
            gem[operation[1]] += x;
        }
        int min_i = 0, max_i = 0;
        for (int i = 1; i < gem.length; i++) {
            if (gem[min_i] > gem[i])
                min_i = i;
            if (gem[max_i] < gem[i])
                max_i = i;
        }
        return gem[max_i] - gem[min_i];

    }
}
